<!DOCTYPE html>
<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<%
String path = request.getContextPath();
String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
%>
<%@taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>
<%@ taglib uri="http://java.sun.com/jsp/jstl/fmt" prefix="fmt"%>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>添加字典内容信息</title>
    <link rel="stylesheet" href="<%=basePath%>web/css/from.css">
    <link rel="stylesheet" href="<%=basePath%>web/themes/default/easyui.css">
    <link rel="stylesheet" href="<%=basePath%>web/themes/icon.css">
    <script src="<%=basePath%>web/js/jquery.min.js"></script>
    <script src="<%=basePath%>web/js/jquery.easyui.min.js"></script>
    <script src="<%=basePath%>web/js/easyui-lang-zh_CN.js"></script>
    <script>
		$(function(){
			var value=$("#value").textbox("getValue");
			value=parseInt(value,10);
			if(value>10&&value<=99){
			   value= "0"+value;
			}else if(value<10&&value>=1){
			   value= "00"+value;
			}
			$("#value").textbox("setValue",value);
					
					
			var sortNumber=$("#sortNumber").textbox("getValue");
			sortNumber=parseInt(sortNumber,10);
			if(sortNumber>10&&sortNumber<=99){
			   sortNumber= "0"+sortNumber;
			}else if(sortNumber<10&&sortNumber>=1){
			   sortNumber= "00"+sortNumber;
			}
			$("#sortNumber").textbox("setValue",sortNumber);
						
	     $("#save").click(function(){
	        var id=$("#id").val();
	        var dictType=$("#dictType").val();
		    var value=$("#value").textbox("getValue");
		    var key=$("#key").textbox("getValue");
		    var sortNumber=$("#sortNumber").textbox("getValue");
		    
       		var reg = new RegExp("^[0-9]+$");
		    if(!reg.test(sortNumber)){  
		        alert("请输入数字!");
		        return;
		    }  
		    var memo=$("#memo").textbox("getValue");
		    var show=$("[name='show']:checked").val();
		    value=parseInt(value,10);	
		    sortNumber=parseInt(sortNumber,10);		    
		    
			       $.ajax({
				      type:"post",//请求类型
				      url:"/kxmanage/dictDetail/updateDict", 
				      data:{"type":dictType,"value":value,"key":key,"sortNumber":sortNumber,"memo":memo,"show":show,"id":id},
				      dataType:"json",//ajax接口（请求url）返回的数据类型
				      success:function(data){//data：返回数据（json对象）
				         if(data.result=="error"){
				          alert("修改失败");
				         }
				         else if(data.result=="success"){
				          alert("修改成功");
		                  parent.addTabs('字典内容管理','goods/dictManagement.jsp');
				          parent.closeTabs('字典内容信息');
				         }
				         else if(data.result=="noPower"){
        				    alert("您没有权限！");
        			     } 
				      }  
			       }); 
	    }); 
	    
	      /* $.ajax({
         	type:"GET",//请求类型
		 	url:"/kxmanage/dictDetail/findalltype",//请求的url
		 	dataType:"json",//ajax接口（请求url）返回的数据类型
		 	success:function(data){//data：返回数据（json对象）
		 		if(data != null){
		 		    var dictType=$("#dictType").val();
		 			$("#dictType").html("");
				var options = "";
				for(var i = 0; i < data.length; i++){
				    if(dictType != null && dictType != undefined && data[i].type == dictType ){
					    options += "<option selected=\"selected\" value=\""+data[i].type+"\">"+data[i].type+"</option>";
					}else{
					    options += "<option value=\""+data[i].type+"\">"+data[i].type+"</option>";
					}
				}
				$("#dictType").html(options);
				}
		 	}
          }); */
	    
         
       });
       
         function reload(){
            parent.addTabs("字典内容信息","/kxmanage/web/goods/addDict.jsp");
         }  
         
         function Close(){
            parent.closeTabs("字典内容信息");
         }
         
                  
    </script>
    <style>
        body {
            font-size:12px;
            padding:10px
        }
        .l-table-edit {
          border-collapse:collapse;
          border-spacing:0;
        }
        .l-table-edit-td {
            padding:4px;
            font-size:12px;
            border:1px solid #84a0c4 
        }
        
    </style>


</head>
<body>
<form name="form"  id="form" action="" method="post">
    <table cellpadding="0" cellspacing="0" class="l-table-edit" style="width:100%">
        <tr >
            <td width="17%"  align="right" class="l-table-edit-td">所属类别：</td>
            <td width="27%" align="left" class="l-table-edit-td">
                 <select name="type" id="dictType" style="width:120px;height:20px" panelHeight="120px" disabled="disabled">
                 	<option value="${dict.type}">${dict.type}</option>
                 </select>  
            </td>
            <td width="13%"  align="right" class="l-table-edit-td">字典编号：</td>
            <td width="43%" align="left" class="l-table-edit-td"><input  type="text" id="value" readonly="readonly" name="value" value="${dict.value}" maxlength="30" class="easyui-textbox" style="height:20px"/></td>
        </tr>
        <tr>
            <td width="17%" align="right" class="l-table-edit-td">字典名称：</td>
            <td width="27%" align="left" class="l-table-edit-td"><input  type="text" id="key" name="key" class="easyui-textbox" value="${dict.key}"  maxlength="50" ltype="text" style="height:20px"/></td>
            <td width="13%" align="right" class="l-table-edit-td">排序编号：</td>
            <td width="43%" align="left" class="l-table-edit-td"><input type="text" id="sortNumber" name="sortNumber" class="easyui-textbox" value="${dict.sortNumber}" maxlength="50"  ltype="text" style="height:20px"/><br/>(请按001格式填写，001为最先)</td>
        </tr>
        <tr>
            <td width="17%" align="right" class="l-table-edit-td">显示状态：</td>
            <td width="27%" align="left" class="l-table-edit-td">
             <input type="radio" name="show" <c:if test="${dict.showStatus==1}">checked</c:if> value="1"/>显示<input type="radio" name="show" <c:if test="${dict.showStatus==2}">checked</c:if> value="2"/>隐藏
            </td>
            <td width="13%" align="right" class="l-table-edit-td">备注：</td>
            <td width="43%"align="left" class="l-table-edit-td"><input type="text"  class="easyui-textbox"  id="memo" name="memo" value="${dict.memo}" maxlength="50"  ltype="text" style="height:20px"/></td>
        </tr>
    </table>
</form>
<br>
<input type="hidden" id="id" value="${dict.id}"/>
<input type="hidden" id="path" value="${pageContext.request.contextPath}"/>
<input  type="button" value="新   增" onclick="reload()" style="width:60px">
<a href="javascript:;"><input id="save" type="button" value="保存" style="width:60px"></a>
<input  type="button" value="打印" style="width:60px">
<input  type="button" onclick="Close()" value="关闭" style="width:60px">
</body>
</html>